<?php
/**
 * The template for displaying Category Archive pages.
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */
get_header();
?>
<?php
$cat_object = $wp_query->get_queried_object();
$parentcat = ($cat_object->category_parent) ? $cat_object->category_parent : $cat;
//echo "<script>alert('".$cat_object->name."')</script>";
?>
<section class="page-top">
    <div class="container">
        <div class="row">
            <div class="span12">
                <ul class="breadcrumb">
                    <?php bcn_display(); ?> 
                </ul>
            </div>
        </div>
        <div class="row">
            <div class="span12">
                <h2><?php echo $cat_object->name; ?></h2>
            </div>
        </div>
    </div>
</section>

<?php if ($cat_object->name == "Portfolio") { ?>
    <?php
    $args = array(
        'show_option_all' => '',
        'orderby' => 'name',
        'order' => 'ASC',
        'style' => 'list',
        'show_count' => 0,
        'hide_empty' => 1,
        'use_desc_for_title' => 1,
        'child_of' => $parentcat,
        'feed' => '',
        'feed_type' => '',
        'feed_image' => '',
        'exclude' => '',
        'exclude_tree' => '',
        'include' => '',
        'hierarchical' => 1,
        'title_li' => __(''),
        'show_option_none' => __('No categories'),
        'number' => null,
        'echo' => 1,
        'depth' => 0,
        'current_category' => 0,
        'pad_counts' => 0,
        'taxonomy' => 'category',
        'walker' => null
    );
    ?>
    <section id="primary">
        <div class="container">
            <h2><?php echo $cat_object->name; ?></h2>
            <ul class="nav nav-pills sort-source" data-option-key="filter" data-sort-id="portfolio">
                <li class="active" data-option-value="*"><a href="#">Show All</a></li>
            <?php wp_list_categories($args); ?>
            </ul>
            <?php if (have_posts()) : ?>

                <?php //twentyeleven_content_nav('nav-above'); ?>

                <?php
                /* Start the Loop */ $x = 0;
                $y = 0;
                $i = 1;
                ?>
                <hr>
                <div class="row">
                    <ul class="portfolio-list sort-destination isotope" data-sort-id="portfolio" style="position: relative; overflow: hidden; height: 1672px;">
					<?php query_posts( array ( 'category_name' => 'Portfolio', 'posts_per_page' => -1 ) ); ?>
                        <?php while (have_posts()) : the_post(); ?>

                            <?php
                            /* Include the Post-Format-specific template for the content.
                             * If you want to overload this in a child theme then include a file
                             * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                             */
                            //get_template_part( 'content', get_post_format() );
                            $category = get_the_category();
                            ?>
                            <li class="span6 isotope-item <?php if ($category[0]->cat_name == "Portfolio") echo $category[1]->cat_name; else echo $category[0]->cat_name; ?>" style="position: absolute; left: 0px; top: 0px; transform: translate3d(<?php if ($i == 1) echo '0px'; else echo '600px'; ?>, <?php echo $y ?>px, 0px);">
                                <div class="portfolio-item thumbnail">
                                    <a class="thumb-info" href="<?php the_permalink(); ?>"> 
                                                <?php
                                                    $image_id = get_post_thumbnail_id();
                                          $image_url = wp_get_attachment_image_src($image_id, 'full', TRUE);?>
                                        <img width="560" height="375" src="<?php echo $image_url[0]; ?>"/>
                                        <span class="thumb-info-title">
                                            <span class="thumb-info-inner"><?php the_title(); ?></span>
                                            <span class="thumb-info-type"><?php if ($category[0]->cat_name == "Portfolio")
                                        echo $category[1]->cat_name; else
                                        echo $category[0]->cat_name;
                                    ?></span>
                                        </span>
                                        <span class="thumb-info-action">
                                            <span class="thumb-info-action-icon" href="#" title="Universal"><i class="icon-link"></i></span>
                                        </span> </a>
                                </div>
                            </li>
                            <?php
                            $i++;
                            if ($i > 2) {
                                $i = 1;
                                $y += 418;
                            }
                            ?>
        <?php endwhile; ?>
                    </ul>
                </div>
        <?php //twentyeleven_content_nav( 'nav-below' );    ?>

    <?php else : ?>

                <article id="post-0" class="post no-results not-found">
                    <header class="entry-header">
                        <h1 class="entry-title"><?php _e('Nothing Found', 'twentyeleven'); ?></h1>
                    </header><!-- .entry-header -->

                    <div class="entry-content">
                        <p><?php _e('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven'); ?></p>
        <?php get_search_form(); ?>
                    </div><!-- .entry-content -->
                </article><!-- #post-0 -->

    <?php endif; ?>

        </div><!-- #content -->
    </section><!-- #primary -->
    <!-- end Portfolio category -->
<?php } else { ?>
    <?php
    $args = array(
        'show_option_all' => '',
        'orderby' => 'name',
        'order' => 'ASC',
        'style' => 'list',
        'show_count' => 0,
        'hide_empty' => 1,
        'use_desc_for_title' => 1,
        'child_of' => $cat,
        'feed' => '',
        'feed_type' => '',
        'feed_image' => '',
        'exclude' => '',
        'exclude_tree' => '',
        'include' => '',
        'hierarchical' => 1,
        'title_li' => __(''),
        'show_option_none' => __('No categories'),
        'number' => null,
        'echo' => 1,
        'depth' => 0,
        'current_category' => 0,
        'pad_counts' => 0,
        'taxonomy' => 'category',
        'walker' => null
    );
    ?>
    <div class="container">

        <div class="row">
            <div class="span9">
                <div class="blog-posts">                    
                    
                    <?php while (have_posts()) : the_post(); ?>
                    <article class="post post-medium-image">
                        <div class="row">
                        <?php if ( has_post_thumbnail() ) { ?>
                            <div class="span4">                                
                                <div class="post-image">
                                    <div data-plugin-options="{&quot;controlNav&quot;:false, &quot;animation&quot;:&quot;slide&quot;, &quot;slideshow&quot;: false, &quot;maxVisibleItems&quot;: 1}" class="flexslider flexslider-center-mobile flexslider-simple normal-device flexslider-init flexslider-direction-nav">

                                        <div class="flex-viewport" style="overflow: hidden; position: relative;"><ul class="slides" style="width: 600%; transition-duration: 0s; transform: translate3d(0px, 0px, 0px);">
                                                <li style="width: 362.5px; float: left; display: block;" class="flex-active-slide">
                                                    <?php the_post_thumbnail('full'); ?>
                                                </li>
                                                <li style="width: 362.5px; float: left; display: block;">
                                                    <?php kd_mfi_the_featured_image( 'featured-image-2', 'post' );?>
                                                </li>
                                                <li style="width: 362.5px; float: left; display: block;">
                                                    <?php kd_mfi_the_featured_image( 'featured-image-3', 'post' );?>
                                                </li>
                                            </ul></div><ul class="flex-direction-nav"><li><a href="#" class="flex-prev flex-disabled">Previous</a></li><li><a href="#" class="flex-next">Next</a></li></ul></div>
                                </div>                                
                            </div>
                            <?php } ?>
                            <?php if ( has_post_thumbnail() ) { ?> <div class="span5"> <?php } ?>

                                <div class="post-content" style="margin-left: 30px;">

                                    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                                    <p><?php the_excerpt(); ?></p>

                                </div>
                            <?php if ( has_post_thumbnail() ) { ?> </div> <?php } ?>

                        </div>
                        <div class="row">
                            <div class="span9">
                                <div class="post-meta">
                                    <span><i class="icon-calendar"></i> <?php the_date(); ?> </span>
                                    <span><i class="icon-user"></i> By <a href="#"><?php the_author(); ?></a> </span>
                                    <span><i class="icon-comments"></i> <a href="#"><?php comments_number( 'no responses', 'one response', '% responses' ); ?></a></span>
                                    <a class="btn btn-mini btn-primary pull-right" href="<?php the_permalink(); ?>">Read more...</a>
                                </div>
                            </div>
                        </div>

                    </article>
                    <?php endwhile; ?>
                    

                    <div class="pagination pagination-large pull-right">
                        <?php
                            global $wp_query;

                            $big = 999999999; // need an unlikely integer

                            echo paginate_links( array(
                                    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
                                    'format' => '?paged=%#%',
                                    'current' => max( 1, get_query_var('paged') ),
                                    'type' => 'list',
                                    'total' => $wp_query->max_num_pages
                            ) );
                        ?>
                    </div>

                </div>
            </div>

            <div class="span3">

                <aside class="sidebar">

                    <form class="form-search" id="searchForm" action="<?php echo esc_url(home_url('/')); ?>" method="get">
                        <div class="input-append">
                            <input type="text" class="span2 search-query" name="s" id="s" placeholder="Search for <?php echo ($cat_object->name); ?>...">
                            <button class="btn btn-primary" type="submit"><i class="icon-search"></i></button>
                        </div>
                    </form>

                    <hr>
                    <h4>Categories</h4>
                    <ul class="nav nav-list primary pull-bottom">
    <?php wp_list_categories($args); ?>
                    </ul>
                    <!--								
                                                                                    
                                                                                            <li><a href="#">Design</a></li>
                                                                                            <li><a href="#">Photos</a></li>
                                                                                            <li><a href="#">Videos</a></li>
                                                                                            <li><a href="#">Lifestyle</a></li>
                                                                                            <li><a href="#">Technology</a></li>
                                                                                    </ul>-->

                    

                    <hr>
    <?php get_sidebar("blog"); ?>

                </aside>
            </div>
        </div>

    </div>
<?php } ?>

<?php get_footer(); ?>
<!-- Libs -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/jquery.js"><\/script>')</script>
<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/jquery.easing.js"></script>
<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/jquery.cookie.js"></script>
<!-- <script src="master/style-switcher/style.switcher.js"></script> -->
<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/bootstrap.js"></script>
<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/selectnav.js"></script>
<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/twitterjs/twitter.js"></script>
<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/flexslider/jquery.flexslider.js"></script>
<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/jflickrfeed/jflickrfeed.js"></script>
<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/fancybox/jquery.fancybox.js"></script>
<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/jquery.validate.js"></script>
<script src="<?php bloginfo('stylesheet_directory'); ?>/vendor/isotope/jquery.isotope.js"></script>

<script src="<?php bloginfo('stylesheet_directory'); ?>/js/plugins.js"></script>

<!-- Page Scripts -->

<!-- Theme Initializer -->
<script src="<?php bloginfo('stylesheet_directory'); ?>/js/theme.js"></script>

<!-- Custom JS -->
<script src="<?php bloginfo('stylesheet_directory'); ?>/js/custom.js"></script>